#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<errno.h>
#define MAXsize 10
//typedef struct SqListNode
//{
//	int data;
//	int size;
//	int capacity;
//}SLNode;
typedef struct SqlistLnode
{
	int data;
	struct SqlistLnode *next;
}SL;
//void SqListInit(SLNode *ps)
//{
//	ps->data = NULL;
//	ps->capacity = 0;
//	ps->size = 0;
//}
//void SqListPushBack(SLNode*ps,int x)
//{
//
//	if (ps->size == ps->capacity)
//	{
//		int newcapacity = ps->capacity == 0 ? 4 : ps->capacity * 2;
//		int *tmp = (int *)realloc(ps->data, newcapacity * 2 * sizeof(int));
//		if (tmp == NULL)
//		{
//			printf("tmp is fail");
//			exit(-1);
//		}
//		else
//		{
//			ps->data = tmp;
//			ps->capacity =newcapacity;
//		}
//	}
//	ps->a[ps->size++] = x;
//	ps->size++;
//}
//void print(SLNode* ps)
//{
//	for (int i = 0; i < ps->size; i++)
//	{
//		printf("%d ", ps->data[i]);
//	}
//	printf("\n");
//}
void SqlistInit(SL*ps)
{
	ps = NULL;
}
//void SlistPushBack(SL *phead, int x)
//{
//	
//}
//void SListPushFron(SL *phead, int x)
//{
//	
//}
void SqList(SL **ps, int x)
{
	SL *newnode = (SL*)malloc(sizeof(SL));
	newnode->data = x;
	newnode->next = NULL;
	if (*ps == NULL)
	{
		*ps = newnode;
	}
	SL *tail = *ps;
	while (tail ->next != NULL)
	{
		tail = tail->next;
	}
	tail->next = newnode; 
}
void SlisPrint(SL* ps)
{
	SL*cur = ps;
	while (cur != NULL)
	{
		printf("%d ", cur->data);
		cur = cur->next;
	}
	printf("\n");
}
int main()
{
	SL Q;
	SqlistInit(&Q);
	SqList(&Q, 1);
	SqList(&Q, 2);
	SqList(&Q, 3);
	SqList(&Q, 4);
	SlisPrint(&Q);
	system("pause");
	return 0;
}